<template>
	<view class="goods-detail" v-if="masterOrderDetail">
		<view class="order-info">
			<view class="order-number" >
				主单号：{{masterOrderDetail.order_num}}
			</view>
			<i class="iconfont icon-copy" @click="copyOrderNumber"/>
			<view class="order-status" :style="{'color':orderStatus.color}">
				{{orderStatus.name}}
			</view>
		</view>
		<view class="goods-detail-main-wrapper">
			<view class="goods-cover-wrapper">
				<image
					:src="masterOrderDetail.product_images"
					style="width: 100%;height: 100%;" mode="aspectFill" />
			</view>
			<view class="goods-info-wrapper">
				<view class="goods-name">
					{{masterOrderDetail.product_name}}
				</view>
				<view class="goods-desc">
					
				</view>
				<view class="goods-price-count-wrapper">
					<view class="goods-count">
						X{{masterOrderDetail.product_num}}
					</view>
					<view class="goods-price">
						<text class="label"></text>￥{{masterOrderDetail.single_price}}
					</view>
				</view>
			</view>
		</view>
		<view class="order-info-bottom">
			<view class="order-createtime">
				{{masterOrderDetail.created_at}}
			</view>
			<view class="total-price">
				<text class="label">共计</text>{{masterOrderDetail.total_price}}
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { defineProps,computed } from 'vue';
	import {IMasterOrderDetail} from "../../types";
	import global from '@/global';
	import { PAY_STATUS } from '@/enum/pay';
	
	interface IProps{
		masterOrderDetail:IMasterOrderDetail|null
	}
	
	const props = withDefaults(defineProps<IProps>(),{
		masterOrderDetail:null
	})
	
	
	const orderStatus = computed(() => {
		if (!props.masterOrderDetail) return null
		if (props.masterOrderDetail.pay_status === PAY_STATUS.PAID) {
			return global.deliverStatusList[props.masterOrderDetail.logistics]
		} else {
			return global.payStatusList[props.masterOrderDetail.pay_status]
		}
	})
	
	
	const copyOrderNumber = ()=>{
		uni.setClipboardData({
			data: props.masterOrderDetail!.order_num!,
			success: () => {
				uni.prompt.$showToast('已复制订单号')
			}
		});
	}
</script>

<style scoped lang="scss">
	@import "./goodsDetail.scss";
</style>